#pragma once
#ifndef __GRID_H__
#define __GRID_H__

#include <Windows.h>
#include <mmsystem.h>
#include <d3dx9.h>

// A structure for our custom vertex type
struct CUSTOMVERTEX
{
    FLOAT x, y, z;      // The untransformed, 3D position for the vertex
    DWORD color;        // The vertex color
};

// Our custom FVF, which describes our custom vertex structure
#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
#define GRID_SIZE (1.0f)
#define INIT_VERTICAL_LEVEL (0.0f)

class Grid
{
public:
	enum
	{
		WIDTH = 32,
		HEIGHT = 32,
	};

private:
	LPDIRECT3DDEVICE9 m_device;
	LPDIRECT3DVERTEXBUFFER9 m_vb; // Buffer to hold vertices
	LPDIRECT3DINDEXBUFFER9 m_ib;

	unsigned short *m_indices;
	CUSTOMVERTEX *m_cur_frame;
	int index_num;
	int vertex_num;

protected:
	void Init();
	void SetupVertices();
	void SetupIndices();

public:
	Grid(LPDIRECT3DDEVICE9 device);
	~Grid();

	void Render();
	void Release();

};

#endif //__GRID_H__